define([], function() {
	return {
		/*title: ['<a href="user.html">个人中心</a>', "系统管理", "用户管理"],*/
		init: function(content) {
			let form = content.children("form");
			let table = content.children("table");
			let search = [];
			let roleId = content.find("select[name='info_certificate_type_id']");
			let roleTemplate = content.find("._roleTemplate");
			let tableInit = function() {
				let actionEvent = {
					"click .temp2": function(e, value, row) {
						toastr.info("查看详情[" + row.userRealName + "]开发中...");
					},
					"click .temp1": function(e, value, row) {
						$.post(
							"user/modify-pwd.do", {
								"userName": row.userName,
								"userPwd": "123456"
							},
							function(data) {
								if(data.ok) {
									toastr.success("重置密码为:123456");
								} else {
									toastr.error("设置锁定状态失败：" + data.message);
								}
							}, "json"
						);
					},
					"change .userLocked": function(e, value, row) {
						e.target.disabled = true;
						$.post(
							"user/modify.do", {
								"userName": row.userName,
								"userLocked": e.target.checked
							},
							function(data) {
								e.target.disabled = false;
								if(data.ok) {
									toastr.success("设置锁定状态成功");
								} else {
									toastr.error("设置锁定状态失败：" + data.message);
								}
							}, "json"
						);
					},
					"change .info_certificate_type_id": function(e, value, row) {
						e.target.disabled = true;
						$.post(
							"user/modify.do", {
								"userName": row.userName,
								"info_certificate_type_id": e.target.value
							},
							function(data) {
								e.target.disabled = false;
								if(data.ok) {
									toastr.success("设置角色成功");
								} else {
									toastr.error("设置角色失败：" + data.message);
								}
							}, "json"
						);
					},
					"click .temp": function(e, value, row) {}
				};
				table.bootstrapTable({
					url: 'certificate/certificate-page.do', // 表格数据来源
					method: "get",
					sidePagination: "server", //分页方式：client客户端分页，server服务端分页（*）
					pageNumber: 1, //初始化加载第一页，默认第一页
					pageSize: 10, //每页的记录行数（*）
					pageList: [5, 10, 15, 20, 30, 50], //可供选择的每页的行数（*）
					pagination: true, //是否显示分页（*）
					dataField: "list",
					toolbar: form,
					queryParamsType: "",
					queryParams: function(p) {
						let ps = [].concat(search);
						ps.push({
							"name": "current",
							"value": p.pageNumber
						});
						ps.push({
							"name": "rowMax",
							"value": p.pageSize
						});
						ps.push({
							"name": "sortName",
							"value": p.sortName
						});
						ps.push({
							"name": "sortOrder",
							"value": p.sortOrder
						});
						return ps;
					},
					columns: [{
							field: 'certificateInfoId',
							title: '证书编号',
							sortable: true,
							sortName: "certificate_info_id",
							width: 100
						}, {
							field: 'infoCertificateTypeId',
							title: '证书类型编号',
							sortable: true,
							sortName: "info_certificate_type_id",
							width: 100
						}, {
							field: 'infoName',
							title: '姓名',
							sortable: true,
							sortName: "info_name",
							align: "center",
							width: 100,
						}, {
							field: 'infoCard',
							sortable: true,
							sortName: "info_card",
							align: "center",
							width: 100,
							title: '身份证号'
						}

					]
					
				});
			};
			form.on("submit", function() {
				search = form.serializeArray();
				table.bootstrapTable('refresh');
				return false;
			});
			$.get(
				"role/list.do",
				function(data) {
					$.each(data, function(i, v) {
						$("<option></option>")
							.val(v.roleId).text(v.roleName)
							.appendTo(roleId);
					});
					tableInit();
				}, "json"
			);
		}
	}
});